<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

        // 改造版 加一个 = {}
        // 如果有值则替换空{}，不传值就用空的
        function ajax2({async=true, type='get', success=function(){}} = {}) {
            console.log(async, type, success);
        }
        ajax2();
        ajax2({ type: 'post' });

        console.log('---------');
        function move({x,y} = { x:0, y:0}) {
            console.log(x, y);
        }
        move() // 0 0
        move({x:3}) // 3 undefined

        /**
         * 使用场景
        */

        // TODO 1. 数据交换
        let a = 1;
        let b = 2;
        [a, b] = [b, a]

        // TODO 2. 多个返回值
        function model() {
            return [1, 2, 3];
        }
        let [a, b, c] = model();

        // TODO 3. 提取json
        let json = {
            id: 1,
            status: 'ok',
            data: [1001, 1002]
        };
        let { id, status, data} = json;
    </script>
</head>
<body>
    
</body>
</html>